# -*- coding: utf-8 -*-
# @Author : zhangxuchuo
# @Date   : 2021/8/12
# @File   : RP02_EntActBeneficiaryCheck_FL.py
# @E-mail : wangbaoshan@bbdservice.com

'''eof
name:实际受益人与申请人不一致
code:RP02_EntActBeneficiaryCheck_FL
tableName:
columnName:
groups:关联方模块
dependencies:OVERVIEW_TAG
type:常用指标
datasourceType:在线指标
description:
eof'''

import sys
import pandas as pd
import json
from datetime import datetime
null_type_list = ['', ' ', None, 'null', 'Null', 'NULL', '/', '-', '--', []]

def RP02_EntActBeneficiaryCheck_FL():
    # data = IC_DSJ_2D.get('data')
    try:
        BENEFICIARY_ARRAY = OVERVIEW_TAG.get('BENEFICIARY_ARRAY', '')
        legalPerson = ratingRequest.get("legalPerson")
        if BENEFICIARY_ARRAY not in null_type_list and legalPerson not in null_type_list and isinstance(BENEFICIARY_ARRAY, list):
            for i in BENEFICIARY_ARRAY:
                name = i.get('BENEFICIARY_NAME')
                if name not in null_type_list and name == legalPerson:
                    return 1
        return 0
    except:
        return '缺失值'

result = RP02_EntActBeneficiaryCheck_FL()

# 风铃-图谱标签数据
# 通过申请人统一社会代码和 统一社会信用代码（goodCompanyOverviewReq.code）进行匹配
# 受益人（BENEFICIARY_NAME）
# if  受益人（BENEFICIARY_NAME） ==申请人姓名：
#     return 1
# else：
#     return 0